package org.shay.springcloud.core.launcher;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.core.Ordered;

/**
 * 启动服务
 *
 * @author shay
 */
public interface LauncherService extends Ordered, Comparable<LauncherService> {
	/**
	 * 启动
	 *
	 * @param builder builder
	 * @param appName app
	 * @param profile env
	 */
	void launcher(SpringApplicationBuilder builder, String appName, String profile);

	/**
	 * 获取排列顺序
	 *
	 * @return order
	 */
	@Override
	default int getOrder() {
		return Ordered.HIGHEST_PRECEDENCE;
	}

	/**
	 * 对比排序
	 *
	 * @param o LauncherService
	 * @return compare
	 */
	@Override
	default int compareTo(LauncherService o) {
		return Integer.compare(this.getOrder(), o.getOrder());
	}
}
